package com.gsh.service.impl;

import com.gsh.dao.AbnormalDao;
import com.gsh.pojo.Abnormal;
import com.gsh.service.IAbnormalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IAbnormalServiceImpl implements IAbnormalService {

    @Autowired
    AbnormalDao abnormalDao;

    @Override
    public int insertAbnormal(Abnormal abnormal) {
        return abnormalDao.insertAbnormal(abnormal);
    }

    @Override
    public int insertBatchAbnormal(List<Abnormal> abnormals) {
        return abnormalDao.insertBatchAbnormal(abnormals);
    }

    @Override
    public List<Abnormal> queryAbnormal(int pageNumber,int pageSize) {
        int startRecord = (pageNumber - 1) * pageSize;
        int maxRecord = pageNumber * pageSize;
        //因为一共只有48条数据
//        if (startRecord >= 48 && startRecord >= pageSize)
//        {
//            startRecord = startRecord - pageSize;
//            maxRecord = maxRecord - pageSize;
//        }
        return abnormalDao.queryAbnormal(startRecord,maxRecord);
    }
}
